#!/usr/bin/env python
# encoding: utf-8
"""
test_atom.py

Created by Dag Brattli on 2008-03-02.
Copyright (c) 2008 __MyCompanyName__. All rights reserved.
"""

import sys
import os
import logging

from elements import atom

def test_atom(filename="tests/atom.xml"):
    data = open(filename).read()
    d = atom.Feed()
    d.from_string(data)
    
    print d.to_string()
    #print repr(d)

    x = d.to_dict()
    assert(x['feed']['title']['$t'] == "Example Feed")
    assert(x['feed']['entry'][0]['summary']['$t'] == "Some text.")

    print x
    
    d = atom.Feed()
    d.from_dict(x)

    assert(d.title.text == "Example Feed")
    assert(d.entry[0].summary.text == "Some text.")
    print d.to_string()

if __name__ == '__main__':
	test_atom("atom.xml")

